##############################################################
#Figure F2: Hurricane Proximity and Authoritarianism
##############################################################

auth1 <- read.dta13("./temp/figf21dta.dta")

newdf <- auth1 %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(5,4,3,2,6,1)
newdf$type <- "Authoritarianism-Independence"
g1<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=coef, ymin=ci_upper, 
                                          ymax=ci_lower), color="black", size=1.2, lwd=1.2, fatten=2, fill="white", shape=21) +
  ylim(-.5,.5) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6"), labels= c("[500,30)", "[400,30)", "[300,30)", "[200,30)", "[100,30)", "[50,30)")) + 
  xlab("Distance Band")  + ylab("Estimate on Authoritarianism") +
  geom_hline(yintercept=0, col="black", lwd=.5, lty="dashed", alpha=.6)  + 
  theme_bw() + theme(panel.grid.major.y = element_blank(),
                     panel.grid.minor.y = element_blank()) + 
  facet_wrap(~type)

g1

rm(auth1, newdf)


auth2 <- read.dta13("./temp/figf22data.dta")

newdf <- auth2 %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(5,4,3,2,6,1)
newdf$type <- "Authoritarianism-Curiosity"
g2<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=coef, ymin=ci_upper, 
                                          ymax=ci_lower), color="black", size=1.2, lwd=1.2, fatten=2, fill="white", shape=21) +
  ylim(-.5,.5) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6"), labels= c("[500,30)", "[400,30)", "[300,30)", "[200,30)", "[100,30)", "[50,30)")) + 
  xlab("Distance Band")  + ylab("Estimate on Authoritarianism") +
  geom_hline(yintercept=0, col="black", lwd=.5, lty="dashed", alpha=.6)  + 
  theme_bw() + theme(panel.grid.major.y = element_blank(),
                     panel.grid.minor.y = element_blank()) + 
  facet_wrap(~type)

g2


auth3 <- read.dta13("./temp/figf23data.dta")

newdf <- auth3 %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(5,4,3,2,6,1)
newdf$type <- "Authoritarianism-Obedience"
g3<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=coef, ymin=ci_upper, 
                                          ymax=ci_lower), color="black", size=1.2, lwd=1.2, fatten=2, fill="white", shape=21) +
  ylim(-.5,.5) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6"), labels= c("[500,30)", "[400,30)", "[300,30)", "[200,30)", "[100,30)", "[50,30)")) + 
  xlab("Distance Band")  + ylab("Estimate on Authoritarianism") +
  geom_hline(yintercept=0, col="black", lwd=.5, lty="dashed", alpha=.6)  + 
  theme_bw() + theme(panel.grid.major.y = element_blank(),
                     panel.grid.minor.y = element_blank()) +
  facet_wrap(~type)

g3


auth4 <- read.dta13("./temp/figf24data.dta")

newdf <- auth4 %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(5,4,3,2,6,1)
newdf$type <- "Authoritarianism-Considerate"
g4<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=coef, ymin=ci_upper, 
                                          ymax=ci_lower), color="black", size=1.2, lwd=1.2, fatten=2, fill="white", shape=21) +
  ylim(-.5,.5) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6"), labels= c("[500,30)", "[400,30)", "[300,30)", "[200,30)", "[100,30)", "[50,30)")) + 
  xlab("Distance Band")  + ylab("Estimate on Authoritarianism") +
  geom_hline(yintercept=0, col="black", lwd=.5, lty="dashed", alpha=.6)  + 
  theme_bw() + theme(panel.grid.major.y = element_blank(),
                     panel.grid.minor.y = element_blank()) + 
  facet_wrap(~type)

g4


library(ggpubr)
ggarrange(g1,g2,g3,g4, ncol=2, nrow=2)
ggsave("./figures/figf2.pdf")
